package com.epower.web.action.epowerword;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.epower.base.BaseAction;
import com.epower.bo.epower.commons.Result;
import com.epower.bo.epowerword.EpowerWordService;
import com.epower.dataobject.EpowerWordDO;

@Scope("prototype")
@Component()
public class EpowerWordAction extends BaseAction {
    
	private static final long serialVersionUID = 1L;
	
	/***查询对象 ***/
	private EpowerWordDO query;
	
	/***对象集合 ***/
	private List<EpowerWordDO> epowerWordList;
	
	/*** BO ***/
	private EpowerWordService epowerWordBO;
	
	/***主键***/
	private Integer id;
	
	/***查询对象 ***/
	private EpowerWordDO epowerWord;
	
	/***当前action所在的namespace ***/
	private String namespace="epowerword";
	/***当前action对应的module ***/
	private String moduleName="EpowerWord";
	
	private Result result = Result.succResult();
	
	/***
	 * 列表视图
	 * @return
	 * @throws Exception
	 */
	public String listEpowerWord() throws Exception {
		//初始化查询条件
		if (query == null) {
			query = new EpowerWordDO();
		}
		//查询列表
		epowerWordList = epowerWordBO.getEpowerWordListPageByOption(query);
		pages = this.getPagesList(query.getToPage(), query.getTotalPage());
		return SUCCESS;
	}
	
	/***
	 * 编辑视图
	 * @return
	 * @throws Exception
	 */
	public String viewEditEpowerWord() throws Exception{
		epowerWord=epowerWordBO.getEpowerWordById(id);
		return SUCCESS;
	}
	
	/***
	 * 编辑操作
	 * @return
	 * @throws Exception
	 */
	 
	public String editEpowerWord()throws Exception{
		if(!epowerWordBO.updateEpowerWordByOption(epowerWord)){
		    addActionMessage("编辑失败");
			return SUCCESS;
		}
		addActionMessage("编辑成功");
		return SUCCESS;
	}
	
	/***
	 * 删除操作
	 * @return
	 * @throws Exception
	 */
	public String deleteEpowerWord()throws Exception{
		if(!epowerWordBO.deleteEpowerWordById(id)){
			addActionMessage("删除失败");
			return SUCCESS;
		}
		addActionMessage("删除成功");
		return SUCCESS;
	}
	/***
	 * 添加视图
	 * @return
	 * @throws Exception
	 */
	public String viewAddEpowerWord()throws Exception{
		return SUCCESS;
	}
	
	/***
	 * 添加操作
	 * @return
	 * @throws Exception
	 */
	public String addEpowerWord()throws Exception{
		if(epowerWordBO.addEpowerWord(epowerWord)==null){
			addActionMessage("添加失败");
			return SUCCESS;
		}
		addActionMessage("添加成功");
		return SUCCESS; 
	}
	
	
	
	/*** setter getter start***/
	public EpowerWordDO getQuery() {
		return query;
	}
	public void setQuery(EpowerWordDO query) {
		this.query = query;
	}
	public List<EpowerWordDO> getEpowerWordList() {
		return epowerWordList;
	}
	public void setEpowerWordList(List<EpowerWordDO> epowerWordList) {
		this.epowerWordList = epowerWordList;
	}
	public EpowerWordService getEpowerWordBO() {
		return epowerWordBO;
	}
	@Resource
	public void setEpowerWordBO(EpowerWordService epowerWordBO) {
		this.epowerWordBO = epowerWordBO;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public EpowerWordDO getEpowerWord() {
		return epowerWord;
	}
	public void setEpowerWord(EpowerWordDO epowerWord) {
		this.epowerWord = epowerWord;
	}
	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}
	
	public String getModuleName() {
		return moduleName;
	}
	public void setModuleName(String moduleName) {
		this.moduleName = moduleName;
	}
	
    public Result getResult() {
        return result;
    }

    public void setResult(Result result) {
        this.result = result;
    }


    /*** setter getter end***/
}

